package oop.core.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import oop.core.view.listeners.ExitGameListener;
import oop.core.view.listeners.ToCharacterCreationMenuListener;
import oop.core.view.listeners.ToControllerConfigMenuListener;

/**
 * Mainmenu is the first menu the user sees that allows them to choose a new game,
 * to load a game, change the controller configuration, or to exit.
 *
 */
public class MainMenu extends SizeablePanel {

	public static final String ID = "MAIN_MENU";
	private static final Dimension SIZE = new Dimension(1000, 800);
	private static final Point LOCATION = new Point(0, 0);
	
	private JButton newGameButton;
	private JButton loadGameButton;
	private JButton controllerConfigButton;
	private JButton exitButton;

	/**
	 * Constructor sets the buttons and layout
	 */
	public MainMenu()
	{
		super(LOCATION, SIZE);
		this.setVisible(true);

		newGameButton = new JButton("New Game");
		newGameButton.setLocation(300, 100);
		newGameButton.setSize(150, 30);
		newGameButton.setVisible(true);
		this.add(newGameButton);

		loadGameButton = new JButton("Load Game");
		loadGameButton.setLocation(300, 200);
		loadGameButton.setSize(150, 30);
		loadGameButton.setVisible(true);
		this.add(loadGameButton);
		
		controllerConfigButton = new JButton("Controls");
		controllerConfigButton.setLocation(300, 300);
		controllerConfigButton.setSize(150, 30);
		controllerConfigButton.setVisible(true);
		this.add(controllerConfigButton);
		
		exitButton = new JButton("Exit");
		exitButton.setLocation(300, 400);
		exitButton.setSize(150, 30);
		exitButton.setVisible(true);
		this.add(exitButton);
	}
	/**
	 * Add all the button listeners
	 * 
	 * @param listener
	 */
	public void addNewGameButtonListener(ActionListener listener)
	{
		newGameButton.addActionListener(listener);
	}
	
	public void addLoadGameButtonListener(ActionListener listener)
	{
		loadGameButton.addActionListener(listener);
	}
	
	public void addControllerConfigButtonListener(ActionListener listener)
	{
		controllerConfigButton.addActionListener(listener);
	}
	
	public void addExitButtonListener(ActionListener listener)
	{
		exitButton.addActionListener(listener);
	}
	
	/**
	 * Render
	 */
	protected void paintComponent(Graphics g)
	{
//		System.out.println("Painting MainMenu");
		g.setColor(Color.CYAN);
		g.fillRect(LOCATION.x, LOCATION.y, SIZE.width, SIZE.height);
	}
}
